<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="主表id" prop="excelId">
        <el-input
          v-model="queryParams.excelId"
          placeholder="请输入主表id"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="取样桩号" prop="qvyzh">
        <el-input
          v-model="queryParams.qvyzh"
          placeholder="请输入取样桩号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="具体位置" prop="jvtwz">
        <el-input
          v-model="queryParams.jvtwz"
          placeholder="请输入具体位置"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="取样深度" prop="qvysd">
        <el-input
          v-model="queryParams.qvysd"
          placeholder="请输入取样深度"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="灌砂前砂容器质量" prop="guansqsrqzl">
        <el-input
          v-model="queryParams.guansqsrqzl"
          placeholder="请输入灌砂前砂容器质量"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="灌砂后砂容器质量" prop="guanshsrqzl">
        <el-input
          v-model="queryParams.guanshsrqzl"
          placeholder="请输入灌砂后砂容器质量"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="锥体砂质量" prop="zhuitszl">
        <el-input
          v-model="queryParams.zhuitszl"
          placeholder="请输入锥体砂质量"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="试坑内砂质量" prop="shiknszl">
        <el-input
          v-model="queryParams.shiknszl"
          placeholder="请输入试坑内砂质量"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="试坑体积" prop="shiktj">
        <el-input
          v-model="queryParams.shiktj"
          placeholder="请输入试坑体积"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="试坑中湿土样质量" prop="shikzstyzl">
        <el-input
          v-model="queryParams.shikzstyzl"
          placeholder="请输入试坑中湿土样质量"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="试坑中湿密度" prop="shikzsmd">
        <el-input
          v-model="queryParams.shikzsmd"
          placeholder="请输入试坑中湿密度"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="盒号" prop="heh">
        <el-input
          v-model="queryParams.heh"
          placeholder="请输入盒号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="盒湿土质量" prop="hestzl">
        <el-input
          v-model="queryParams.hestzl"
          placeholder="请输入盒湿土质量"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="盒干土质量" prop="hegtzl">
        <el-input
          v-model="queryParams.hegtzl"
          placeholder="请输入盒干土质量"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="水质量" prop="shuizl">
        <el-input
          v-model="queryParams.shuizl"
          placeholder="请输入水质量"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="盒质量" prop="hezl">
        <el-input
          v-model="queryParams.hezl"
          placeholder="请输入盒质量"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="干土质量" prop="gantzl">
        <el-input
          v-model="queryParams.gantzl"
          placeholder="请输入干土质量"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="含水率" prop="hansl">
        <el-input
          v-model="queryParams.hansl"
          placeholder="请输入含水率"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="含水率均值" prop="hansljz">
        <el-input
          v-model="queryParams.hansljz"
          placeholder="请输入含水率均值"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="干密度" prop="ganmd">
        <el-input
          v-model="queryParams.ganmd"
          placeholder="请输入干密度"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="最大干密度" prop="zuidgmd">
        <el-input
          v-model="queryParams.zuidgmd"
          placeholder="请输入最大干密度"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="最佳含水率" prop="zuijhsl">
        <el-input
          v-model="queryParams.zuijhsl"
          placeholder="请输入最佳含水率"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="压实度" prop="yasd">
        <el-input
          v-model="queryParams.yasd"
          placeholder="请输入压实度"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['report_ljlm:ysdgsfjlbBsDetail:add']"
        >新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['report_ljlm:ysdgsfjlbBsDetail:edit']"
        >修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['report_ljlm:ysdgsfjlbBsDetail:remove']"
        >删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['report_ljlm:ysdgsfjlbBsDetail:export']"
        >导出</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="ysdgsfjlbBsDetailList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="" align="center" prop="id" v-if="true"/>
      <el-table-column label="主表id" align="center" prop="excelId" />
      <el-table-column label="取样桩号" align="center" prop="qvyzh" />
      <el-table-column label="具体位置" align="center" prop="jvtwz" />
      <el-table-column label="取样深度" align="center" prop="qvysd" />
      <el-table-column label="灌砂前砂容器质量" align="center" prop="guansqsrqzl" />
      <el-table-column label="灌砂后砂容器质量" align="center" prop="guanshsrqzl" />
      <el-table-column label="锥体砂质量" align="center" prop="zhuitszl" />
      <el-table-column label="试坑内砂质量" align="center" prop="shiknszl" />
      <el-table-column label="试坑体积" align="center" prop="shiktj" />
      <el-table-column label="试坑中湿土样质量" align="center" prop="shikzstyzl" />
      <el-table-column label="试坑中湿密度" align="center" prop="shikzsmd" />
      <el-table-column label="盒号" align="center" prop="heh" />
      <el-table-column label="盒湿土质量" align="center" prop="hestzl" />
      <el-table-column label="盒干土质量" align="center" prop="hegtzl" />
      <el-table-column label="水质量" align="center" prop="shuizl" />
      <el-table-column label="盒质量" align="center" prop="hezl" />
      <el-table-column label="干土质量" align="center" prop="gantzl" />
      <el-table-column label="含水率" align="center" prop="hansl" />
      <el-table-column label="含水率均值" align="center" prop="hansljz" />
      <el-table-column label="干密度" align="center" prop="ganmd" />
      <el-table-column label="最大干密度" align="center" prop="zuidgmd" />
      <el-table-column label="最佳含水率" align="center" prop="zuijhsl" />
      <el-table-column label="压实度" align="center" prop="yasd" />
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['report_ljlm:ysdgsfjlbBsDetail:edit']"
          >修改</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['report_ljlm:ysdgsfjlbBsDetail:remove']"
          >删除</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改路基路面压实度试验检测记录(灌砂法)详情对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-form-item label="主表id" prop="excelId">
          <el-input v-model="form.excelId" placeholder="请输入主表id" />
        </el-form-item>
        <el-form-item label="取样桩号" prop="qvyzh">
          <el-input v-model="form.qvyzh" placeholder="请输入取样桩号" />
        </el-form-item>
        <el-form-item label="具体位置" prop="jvtwz">
          <el-input v-model="form.jvtwz" placeholder="请输入具体位置" />
        </el-form-item>
        <el-form-item label="取样深度" prop="qvysd">
          <el-input v-model="form.qvysd" placeholder="请输入取样深度" />
        </el-form-item>
        <el-form-item label="灌砂前砂容器质量" prop="guansqsrqzl">
          <el-input v-model="form.guansqsrqzl" placeholder="请输入灌砂前砂容器质量" />
        </el-form-item>
        <el-form-item label="灌砂后砂容器质量" prop="guanshsrqzl">
          <el-input v-model="form.guanshsrqzl" placeholder="请输入灌砂后砂容器质量" />
        </el-form-item>
        <el-form-item label="锥体砂质量" prop="zhuitszl">
          <el-input v-model="form.zhuitszl" placeholder="请输入锥体砂质量" />
        </el-form-item>
        <el-form-item label="试坑内砂质量" prop="shiknszl">
          <el-input v-model="form.shiknszl" placeholder="请输入试坑内砂质量" />
        </el-form-item>
        <el-form-item label="试坑体积" prop="shiktj">
          <el-input v-model="form.shiktj" placeholder="请输入试坑体积" />
        </el-form-item>
        <el-form-item label="试坑中湿土样质量" prop="shikzstyzl">
          <el-input v-model="form.shikzstyzl" placeholder="请输入试坑中湿土样质量" />
        </el-form-item>
        <el-form-item label="试坑中湿密度" prop="shikzsmd">
          <el-input v-model="form.shikzsmd" placeholder="请输入试坑中湿密度" />
        </el-form-item>
        <el-form-item label="盒号" prop="heh">
          <el-input v-model="form.heh" placeholder="请输入盒号" />
        </el-form-item>
        <el-form-item label="盒湿土质量" prop="hestzl">
          <el-input v-model="form.hestzl" placeholder="请输入盒湿土质量" />
        </el-form-item>
        <el-form-item label="盒干土质量" prop="hegtzl">
          <el-input v-model="form.hegtzl" placeholder="请输入盒干土质量" />
        </el-form-item>
        <el-form-item label="水质量" prop="shuizl">
          <el-input v-model="form.shuizl" placeholder="请输入水质量" />
        </el-form-item>
        <el-form-item label="盒质量" prop="hezl">
          <el-input v-model="form.hezl" placeholder="请输入盒质量" />
        </el-form-item>
        <el-form-item label="干土质量" prop="gantzl">
          <el-input v-model="form.gantzl" placeholder="请输入干土质量" />
        </el-form-item>
        <el-form-item label="含水率" prop="hansl">
          <el-input v-model="form.hansl" placeholder="请输入含水率" />
        </el-form-item>
        <el-form-item label="含水率均值" prop="hansljz">
          <el-input v-model="form.hansljz" placeholder="请输入含水率均值" />
        </el-form-item>
        <el-form-item label="干密度" prop="ganmd">
          <el-input v-model="form.ganmd" placeholder="请输入干密度" />
        </el-form-item>
        <el-form-item label="最大干密度" prop="zuidgmd">
          <el-input v-model="form.zuidgmd" placeholder="请输入最大干密度" />
        </el-form-item>
        <el-form-item label="最佳含水率" prop="zuijhsl">
          <el-input v-model="form.zuijhsl" placeholder="请输入最佳含水率" />
        </el-form-item>
        <el-form-item label="压实度" prop="yasd">
          <el-input v-model="form.yasd" placeholder="请输入压实度" />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button :loading="buttonLoading" type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { listYsdgsfjlbBsDetail, getYsdgsfjlbBsDetail, delYsdgsfjlbBsDetail, addYsdgsfjlbBsDetail, updateYsdgsfjlbBsDetail } from "@/api/report_ljlm/ysdgsfjlbBsDetail";

export default {
  name: "YsdgsfjlbBsDetail",
  data() {
    return {
      // 按钮loading
      buttonLoading: false,
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 路基路面压实度试验检测记录(灌砂法)详情表格数据
      ysdgsfjlbBsDetailList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        excelId: undefined,
        qvyzh: undefined,
        jvtwz: undefined,
        qvysd: undefined,
        guansqsrqzl: undefined,
        guanshsrqzl: undefined,
        zhuitszl: undefined,
        shiknszl: undefined,
        shiktj: undefined,
        shikzstyzl: undefined,
        shikzsmd: undefined,
        heh: undefined,
        hestzl: undefined,
        hegtzl: undefined,
        shuizl: undefined,
        hezl: undefined,
        gantzl: undefined,
        hansl: undefined,
        hansljz: undefined,
        ganmd: undefined,
        zuidgmd: undefined,
        zuijhsl: undefined,
        yasd: undefined,
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
        id: [
          { required: true, message: "不能为空", trigger: "blur" }
        ],
        excelId: [
          { required: true, message: "主表id不能为空", trigger: "blur" }
        ],
        qvyzh: [
          { required: true, message: "取样桩号不能为空", trigger: "blur" }
        ],
        jvtwz: [
          { required: true, message: "具体位置不能为空", trigger: "blur" }
        ],
        qvysd: [
          { required: true, message: "取样深度不能为空", trigger: "blur" }
        ],
        guansqsrqzl: [
          { required: true, message: "灌砂前砂容器质量不能为空", trigger: "blur" }
        ],
        guanshsrqzl: [
          { required: true, message: "灌砂后砂容器质量不能为空", trigger: "blur" }
        ],
        zhuitszl: [
          { required: true, message: "锥体砂质量不能为空", trigger: "blur" }
        ],
        shiknszl: [
          { required: true, message: "试坑内砂质量不能为空", trigger: "blur" }
        ],
        shiktj: [
          { required: true, message: "试坑体积不能为空", trigger: "blur" }
        ],
        shikzstyzl: [
          { required: true, message: "试坑中湿土样质量不能为空", trigger: "blur" }
        ],
        shikzsmd: [
          { required: true, message: "试坑中湿密度不能为空", trigger: "blur" }
        ],
        heh: [
          { required: true, message: "盒号不能为空", trigger: "blur" }
        ],
        hestzl: [
          { required: true, message: "盒湿土质量不能为空", trigger: "blur" }
        ],
        hegtzl: [
          { required: true, message: "盒干土质量不能为空", trigger: "blur" }
        ],
        shuizl: [
          { required: true, message: "水质量不能为空", trigger: "blur" }
        ],
        hezl: [
          { required: true, message: "盒质量不能为空", trigger: "blur" }
        ],
        gantzl: [
          { required: true, message: "干土质量不能为空", trigger: "blur" }
        ],
        hansl: [
          { required: true, message: "含水率不能为空", trigger: "blur" }
        ],
        hansljz: [
          { required: true, message: "含水率均值不能为空", trigger: "blur" }
        ],
        ganmd: [
          { required: true, message: "干密度不能为空", trigger: "blur" }
        ],
        zuidgmd: [
          { required: true, message: "最大干密度不能为空", trigger: "blur" }
        ],
        zuijhsl: [
          { required: true, message: "最佳含水率不能为空", trigger: "blur" }
        ],
        yasd: [
          { required: true, message: "压实度不能为空", trigger: "blur" }
        ],
      }
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询路基路面压实度试验检测记录(灌砂法)详情列表 */
    getList() {
      this.loading = true;
      listYsdgsfjlbBsDetail(this.queryParams).then(response => {
        this.ysdgsfjlbBsDetailList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: undefined,
        excelId: undefined,
        qvyzh: undefined,
        jvtwz: undefined,
        qvysd: undefined,
        guansqsrqzl: undefined,
        guanshsrqzl: undefined,
        zhuitszl: undefined,
        shiknszl: undefined,
        shiktj: undefined,
        shikzstyzl: undefined,
        shikzsmd: undefined,
        heh: undefined,
        hestzl: undefined,
        hegtzl: undefined,
        shuizl: undefined,
        hezl: undefined,
        gantzl: undefined,
        hansl: undefined,
        hansljz: undefined,
        ganmd: undefined,
        zuidgmd: undefined,
        zuijhsl: undefined,
        yasd: undefined,
        delFlag: undefined,
        createBy: undefined,
        createTime: undefined,
        updateBy: undefined,
        updateTime: undefined
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加路基路面压实度试验检测记录(灌砂法)详情";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.loading = true;
      this.reset();
      const id = row.id || this.ids
      getYsdgsfjlbBsDetail(id).then(response => {
        this.loading = false;
        this.form = response.data;
        this.open = true;
        this.title = "修改路基路面压实度试验检测记录(灌砂法)详情";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          this.buttonLoading = true;
          if (this.form.id != null) {
            updateYsdgsfjlbBsDetail(this.form).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            }).finally(() => {
              this.buttonLoading = false;
            });
          } else {
            addYsdgsfjlbBsDetail(this.form).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            }).finally(() => {
              this.buttonLoading = false;
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$modal.confirm('是否确认删除路基路面压实度试验检测记录(灌砂法)详情编号为"' + ids + '"的数据项？').then(() => {
        this.loading = true;
        return delYsdgsfjlbBsDetail(ids);
      }).then(() => {
        this.loading = false;
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => {
      }).finally(() => {
        this.loading = false;
      });
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('report_ljlm/ysdgsfjlbBsDetail/export', {
        ...this.queryParams
      }, `ysdgsfjlbBsDetail_${new Date().getTime()}.xlsx`)
    }
  }
};
</script>
